﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;


namespace Deployment.Data.Variable
{
    public class AbstractVariableEditorControl : UserControl
    {
        public static readonly DependencyProperty EnvironmentsProperty =
            DependencyProperty.Register("Environments",
                typeof(Environment.EnvironmentsFile),
                typeof(AbstractVariableEditorControl));

        public static readonly DependencyProperty SelectedEnvironmentProperty =
            DependencyProperty.Register("SelectedEnvironment",
                typeof(Environment.Environment),
                typeof(AbstractVariableEditorControl));

        public static readonly DependencyProperty VariablesListProperty =
            DependencyProperty.Register("Variables",
                typeof(VariablesFile),
                typeof(AbstractVariableEditorControl));

        public static readonly DependencyProperty VariableProperty =
            DependencyProperty.Register("Variable",
                typeof(AbstractVariable),
                typeof(AbstractVariableEditorControl));

        public static readonly DependencyProperty ContentOkProperty =
            DependencyProperty.Register("ContentOk",
                typeof(bool),
                typeof(AbstractVariableEditorControl));

        public event DependencyPropertyChangedEventHandler PropertyChanged;

        public AbstractVariableEditorControl()
        {
            this.DataContext = this;
        }

        protected internal void SetValueDp(DependencyProperty property, object value)
        {
            SetValue(property, value);
            if (PropertyChanged != null)
                PropertyChanged(this, new DependencyPropertyChangedEventArgs());
        }

        public Environment.EnvironmentsFile Environments
        {
            get { return (Environment.EnvironmentsFile)GetValue(EnvironmentsProperty); }
            set { SetValueDp(EnvironmentsProperty, value); }
        }

        public VariablesFile Variables
        {
            get { return (VariablesFile)GetValue(VariablesListProperty); }
            set { SetValueDp(VariablesListProperty, value); }
        }

        public Environment.Environment SelectedEnvironment
        {
            get { return (Environment.Environment)GetValue(SelectedEnvironmentProperty); }
            set { SetValueDp(SelectedEnvironmentProperty, value); }
        }

        public AbstractVariable Variable
        {
            get { return (AbstractVariable)GetValue(VariableProperty); }
            set { SetValueDp(VariableProperty, value); }
        }



        public bool ContentOk
        {
            get { return (bool)GetValue(ContentOkProperty); }
            set { SetValueDp(ContentOkProperty, value); }
        }
    }
}
